<?php
/* Description: This file is used to add sub sub category. */
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/Vendor/Vendor.php';
require_once _SITE_PATH_.'classes/Master/Master.php';
require_once _SITE_PATH_.'classes/Product/Product.php';
require_once _SITE_PATH_.'classes/Content/Content.php';
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';

$id = trim($_REQUEST['id']);

if( $_POST['submit']=='Submit'){   
	$parms['id'] = $_POST['id'];
	
	$parms['title'] = $_POST['title'];
	$parms['entity_type'] = $_POST['entity_type'];
	
	if($parms['entity_type'] == 1){
		$parms['entity_id'] = $_POST['service'];
	}else if($parms['entity_type'] == 2){
		$parms['entity_id'] = $_POST['product'];
	}
	
	$parms['summary'] = $_POST['summary'];
	$parms['description'] = $_POST['description'];
	$parms['added'] = date("Y-m-d");
	 
	$condition['id'] = $parms['id'];
	
    if( CommonUtility::updateData($parms, 'news', $condition)) {        
        header("Location: news_mng.php?msg=1606");            
        exit;
    }
    $err = 1607;    
}

$editor = CommonUtility::includeEditor();

$news = array();
$news = Content::getNewsList($id);
$result = $news[0];

$sid = '';
$pid = '';
$service_display = 'none';
$product_display = 'none';

if($result['entity_type'] == 1){
	$sid = $result['entity_id'];
	$service_display = 'block';
}else if($result['entity_type'] == 2){
	$pid = $result['entity_id'];
	$product_display = 'block';	
}

$services = array();
$services = Master::getActiveServices($sid);

$products = array();
$products = Product::getActiveProducts($pid);

$errMsg = $err;
$_tplName = 'content/news_edit.tpl';
$_title = 'Edit News';

require_once _ADMIN_TPL_MAIN_;
?>